//
//  ShowInfoView.m
//  JinFuThree
//
//  Created by 毛韶谦 on 2018/9/5.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "ShowInfoView.h"

@interface ShowInfoView ()

@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *infoLabel;

@end

@implementation ShowInfoView


/**
 展示信息页面

 @param view 添加到View
 @param image 需要的图片
 @param title 提示信息
 @param infoStr 详情信息
 */
+(void)ShowInfoView:(UIView *)view withImage:(UIImage *)image WithTitle:(NSString *)title WithInfo:(NSString *)infoStr {
    
    ShowInfoView *infoView = [[ShowInfoView alloc] initWithFrame:view.bounds];
    infoView.backgroundColor = [UIColor whiteColor];
    infoView.imageView.image = image;
    infoView.titleLabel.text = title;
    infoView.infoLabel.text = infoStr;
    [view addSubview:infoView];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.size.mas_equalTo(CGSizeMake(130, 160));
            make.top.mas_equalTo(self.mas_top).offset(100);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.left.mas_equalTo(self.mas_left).offset(20);
            make.top.mas_equalTo(self.imageView.mas_bottom).offset(8);
        }];
        [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(8);
            make.left.mas_equalTo(self.mas_left).offset(20);
        }];
    }
    return self;
}


- (UIImageView *)imageView {
    
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
        [_imageView setContentMode:UIViewContentModeScaleAspectFit];
        
        [self addSubview:_imageView];
    }
    return _imageView;
}
- (UILabel *)titleLabel {
    
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        [_titleLabel setTextAlignment:NSTextAlignmentCenter];
        _titleLabel.font = [UIFont boldSystemFontOfSize:16];
        _titleLabel.textColor = HexColor(0x333333);
        
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}
- (UILabel *)infoLabel {
    
    if (!_infoLabel) {
        _infoLabel = [[UILabel alloc] init];
        [_infoLabel setTextAlignment:NSTextAlignmentCenter];
        _infoLabel.font = [UIFont systemFontOfSize:14];
        _infoLabel.textColor = HexColor(0x666666);
        _infoLabel.numberOfLines = 0;
        
        [self addSubview:_infoLabel];
    }
    return _infoLabel;
}





/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
